<?php
include_once 'include.php';
check_login();#检查是否登录
$total = sql_count('lyy_ziliao','del=1');#总行数
$curr = isset($_REQUEST['curr'])?$_REQUEST['curr']:1;#当前页
$limit = 10;#每页多少行
$page = ceil($total/$limit);#总共有多少页
$offset = ($curr-1)*$limit;
$sql = "select a.id,a.title,a.createtime,a.type,a.file_url,b.username from lyy_ziliao a 
JOIN lyy_member b ON a.uid=b.id WHERE a.del=1 limit $offset,$limit";
$res = mysqli_query(conn(),$sql);
$lists = mysqli_fetch_all($res,MYSQLI_ASSOC);#资料列表
?>
<!DOCTYPE html>
<html>
<head>
    <?php include_once 'common_js_css.php'?>
	<link rel="stylesheet" type="text/css" href="css/common1.css">
    <link rel="stylesheet" type="text/css" href="css/adziliaobiao.css">
</head>
<body>
<div class="cont" style="height: 730px">
    <h1 style="text-align: center;">课程资料列表</h1>
    <form id="form1" style="margin-left: 40px;margin-top: 40px">
      <table width="1000" border="0" align="center" cellspacing="0">
        <tr>
          <th width="45" height="30" scope="col">序号</th>
          <th width="300" height="30" scope="col">课程名称</th>
          <th width="200" scope="col">课程类型</th>
          <th width="200" scope="col">资源包</th>
          <th width="100" height="30" scope="col">发布者</th>
          <th width="200" height="30" scope="col">发布时间</th>
          <th width="200" height="30" scope="col">&nbsp;</th>
        </tr>
          <?php foreach ($lists as $list): ?>
        <tr>
          <td height="30" align="center"><?php echo $list['id']; ?></td>
          <td height="50" align="center"><p><?php echo $list['title']; ?></p></td>
          <td height="50" align="center">
              <?php if ($list['type']==1) echo 'PPT';else echo 'SWF'; ?>
          </td>
          <td height="50" align="center"><a href="<?php echo $list['file_url']; ?>">下载资源</a></td>
          <td height="30" align="center"><?php echo $list['username']; ?></td>
          <td height="30" align="center"><?php echo date("Y-m-d H:i:s",$list['createtime']); ?></td>
          <td height="30" align="center"><input type="submit" onclick="del('lyy_ziliao','<?php echo $list['id'];?>')" value="删除">
              <input  class="container" type="submit" onclick="xiugai('<?php echo $list['id']; ?>','<?php echo $list['title']; ?>','<?php echo $list['type']; ?>','<?php echo $list['file_url']; ?>')" value="修改"></td>
        </tr>
          <?php endforeach; ?>
          <tr>
              <td colspan="7" align="center">
                  <!--显示分页，只有一页，即不显示分页-->
                  <?php if($total>$limit){echo showPage($curr,$page);}?>
                  <input name="Submit2" class="print" type="button" onClick="javascript:window.print();" value="打印本页" />
              </td>
          </tr>
      </table>
    </form>
</div>

<!--修改弹窗-->
<div class="fulled">
    <div class="fix-box">
        <p class="close">关闭</p>
        <span>修改</span>
        <table width="900"  align="center" cellspacing="0">
            <tr>
                <td width="90" height="40" align="center">练习名称</td>
                <td width="350" height="30">
                    <input type="text" id="id" style="display: none" value="">
                    <input type="text" id="title" value="">
                </td>
            </tr>
            <tr>
                <td align="center" height="40">资料类型</td>
                <td>
                    <select name="kejian" id="type">
                        <option value="1" selected>PPT</option>
                        <option value="2">SWF</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td height="40" align="center">内容</td>
                <td >
                    <input type="file" name="file_url" id="file" onchange="upload_file()">
                    <input type="text" id="file_name" style="display: none"></td>
            </tr>
            <tr>
                <td colspan="4" align="center" height="50">
                    <input type="button" value="修改" onclick="update_kecheng('lyy_ziliao','adlist_ziliao.php')">
                </td>
            </tr>
        </table>
    </div>
</div>
</body>
</html>